//
//  YXUtilities.h
//  YXImageBrowserDemo
//
//  Created by guo peng huang on 2021/5/17.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

#define YX_DISPATCH_ASYNC(queue, block)\
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) {\
block();\
} else {\
dispatch_async(queue, block);\
}

#define YX_DISPATCH_ASYNC_MAIN(block) YX_DISPATCH_ASYNC(dispatch_get_main_queue(), block)


#define YX_CODE_EXEC_TIME(KEY, ...) \
CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent(); \
__VA_ARGS__ \
CFAbsoluteTime linkTime = (CFAbsoluteTimeGetCurrent() - startTime); \
NSLog(@"%@ Time-Consuming: %fms", KEY, linkTime * 1000.0);

UIWindow * _Nonnull YXNormalWindow(void);

UIViewController * _Nullable YXTopController(void);
UIViewController * _Nullable YXTopControllerByWindow(UIWindow *);

BOOL YXLowMemory(void);

BOOL YXIsIphoneXDevice(void);
CGFloat YXStatusbarHeight(void);
CGFloat YXSafeAreaBottomHeight(void);

UIImage *YXSnapshotView(UIView *);

/// This is orientation of 'YXImageBrowser' not 'UIDevice'.
UIEdgeInsets YXPaddingByBrowserOrientation(UIDeviceOrientation);

@interface YXUtilities : NSObject

@end

NS_ASSUME_NONNULL_END
